package org.example.rubbish.mapper;


import org.apache.ibatis.annotations.*;
import org.example.rubbish.entity.DeviceControl;

@Mapper
public interface DeviceControlMapper {
    @Insert("INSERT INTO device_control(station_id, light_on_time, light_off_time, door_close_delay, operator) " +
            "VALUES(#{stationId}, #{lightOnTime}, #{lightOffTime}, #{doorCloseDelay}, #{operator})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(DeviceControl control);

    @Update("UPDATE device_control SET light_on_time=#{lightOnTime}, light_off_time=#{lightOffTime}, " +
            "door_close_delay=#{doorCloseDelay}, operator=#{operator}, update_time=NOW() WHERE id=#{id}")
    void update(DeviceControl control);

    @Select("SELECT * FROM device_control WHERE station_id=#{stationId}")
    DeviceControl selectByStationId(Long stationId);
}